<?php

return [
    'common' => [
        // bootstrap文件, 只会引入一次
        'bootstrapFile' => [
            __DIR__ . '/../../common/config/bootstrap.php',
        ],
        // Yii的配置文件, 只会引入一次
        'configFile' => [
            __DIR__ . '/../../common/config/main.php',
            __DIR__ . '/../../common/config/main-local.php',
            __DIR__ . '/../../apis/config/main.php',
            __DIR__ . '/../../apis/config/main-local.php'
        ],
        // 有一些模块比较特殊, 无法实现Refreshable接口, 此时唯有在这里指定他的类名
        'bootstrapRefresh' => [],
        'root' => realpath(__DIR__ . '/../../apis/web'),
        'reload_path' => Yii::getAlias('@apis'),//热部署监控目录
    ],
    'web' => [
        'host' => '0.0.0.0',
        'port' => '80',
        'name' => 'swoole-webServer',
        'use_taskserver' => false,
        'type' => SWOOLE_BASE,
        // 配置参考 https://www.kancloud.cn/admins/swoole/201155
        'pidFile' => sys_get_temp_dir() . '/swooleweb.pid',
        'wsAuth' => [
            'class' => \yii\swoole\websocket\WebsocketAuth::class
        ],
        'wsSend' => [
            'class' => \yii\swoole\websocket\WsSendCtrl::class
        ],
        'server' => [
            'upload_tmp_dir' => '/data/uploadfiles',
            'worker_num' => 1, //worker process num
            'backlog' => 1280, //listen backlog
            'dispatch_mode' => 1,
            'max_request' => 100000,
            'task_worker_num' => 1,
            'log_file' => dirname(dirname(__DIR__)) . '/runtime/logs/swoole_web.log',
            'log_level' => 0,
            'daemonize' => 0,
            'open_cpu_affinity' => true,
            'open_tcp_nodelay' => true,
            'buffer_output_size' => 32 * 1024 * 1024,
            'pid_file' => sys_get_temp_dir() . '/swooleweb.pid',
            'heartbeat_check_interval' => 60,
            'heartbeat_idle_time' => 600,
            'tcp_defer_accept' => 5,
            'enable_reuse_port' => true,
            'enable_unsafe_event' => false,
            'http_parse_post' => true,
            'max_coro_num' => 10000,
            'reload_async' => true
        ],
    ],
    'rpc' => [
        'host' => current(swoole_get_local_ip()),//公网访问需配置ip
        'port' => '9503',
        'name' => 'swoole-tcpServer',
        'pidFile' => sys_get_temp_dir() . '/swooletcp.pid',
        'server' => [
            'worker_num' => swoole_cpu_num(), //worker process num
            'backlog' => 1280, //listen backlog
            'daemonize' => 0,
            'open_length_check' => 0,
            'package_length_type' => 'N',
            'package_length_offset' => 0,
            'package_length_type_len' => 4,
            'package_body_offset' => 4,
            'package_max_length' => 2097152, // 1024 * 1024 * 2,
            'buffer_output_size' => 3145728, //1024 * 1024 * 3,
            'pipe_buffer_size' => 33554432, // 1024 * 1024 * 32,
            'open_tcp_nodelay' => 1,
            'log_file' => dirname(dirname(__DIR__)) . '/runtime/logs/swoole_tcp.log',
            'heartbeat_check_interval' => 5,
            'heartbeat_idle_time' => 60,
            'tcp_defer_accept' => 5,
            'enable_reuse_port' => true,
            'pid_file' => sys_get_temp_dir() . '/swooletcp.pid',
            'enable_unsafe_event' => false,
            'open_cpu_affinity' => 1,
            'reload_async' => true,
            'max_request' => 100000
        ]
    ],
    'udp' => [
        'host' => '0.0.0.0',//公网访问需配置ip
        'port' => '9502',
        'name' => 'swoole-udpServer',
        'pidFile' => sys_get_temp_dir() . '/swooleudp.pid',
        'server' => [
            'worker_num' => swoole_cpu_num(), //worker process num
            'backlog' => 1280, //listen backlog
            'daemonize' => 0,
            'buffer_output_size' => 3145728, //1024 * 1024 * 3,
            'pipe_buffer_size' => 33554432, // 1024 * 1024 * 32,
            'log_file' => dirname(dirname(__DIR__)) . '/runtime/logs/swoole_udp.log',
            'enable_reuse_port' => true,
            'pid_file' => sys_get_temp_dir() . '/swooleudp.pid',
            'open_cpu_affinity' => 1,
            'reload_async' => true,
            'max_request' => 100000
        ]
    ],
    'mqtt' => [
        'host' => '0.0.0.0',//公网访问需配置ip
        'port' => '9504',
        'name' => 'swoole-mqttServer',
        'pidFile' => sys_get_temp_dir() . '/swoolemqtt.pid',
        'server' => [
            'worker_num' => swoole_cpu_num(), //worker process num
            'backlog' => 1280, //listen backlog
            'daemonize' => 0,
            'buffer_output_size' => 3145728, //1024 * 1024 * 3,
            'pipe_buffer_size' => 33554432, // 1024 * 1024 * 32,
            'open_tcp_nodelay' => 1,
            'log_file' => dirname(dirname(__DIR__)) . '/runtime/logs/swoole_mqtt.log',
            'heartbeat_check_interval' => 5,
            'heartbeat_idle_time' => 60,
            'tcp_defer_accept' => 5,
            'enable_reuse_port' => true,
            'pid_file' => sys_get_temp_dir() . '/swoolemqtt.pid',
            'enable_unsafe_event' => false,
            'open_cpu_affinity' => 1,
            'reload_async' => true,
            'open_mqtt_protocol' => true,
            'max_request' => 100000
        ]
    ],
    'task' => [
        'host' => '0.0.0.0',
        'port' => '9505',
        'name' => 'swoole-taskServer',
        'pidFile' => sys_get_temp_dir() . '/swooletask.pid',
        'server' => [
            'daemonize' => 0,
            'task_worker_num' => swoole_cpu_num() * 2,
            'open_length_check' => 0,
            'package_length_type' => 'N',
            'package_length_offset' => 0,
            'package_length_type_len' => 4,
            'package_body_offset' => 4,
            'package_max_length' => 2097152, // 1024 * 1024 * 2,
            'buffer_output_size' => 3145728, //1024 * 1024 * 3,
            'pipe_buffer_size' => 33554432, // 1024 * 1024 * 32,
            'open_tcp_nodelay' => 1,
            'backlog' => 128,
            'log_file' => dirname(dirname(__DIR__)) . '/runtime/logs/swoole_task.log',
            'reload_async' => true,
            'max_request' => 100000
        ]
    ]
];
